//
//  UIFont+runtime.m
//  LabelRuntimeChangeFont
//
//  Created by Rongjun Jiang on 2018/4/23.
//  Copyright © 2018年 Rongjun Jiang. All rights reserved.
//

#import "UIFont+runtime.h"
#import <objc/runtime.h>

@implementation UIFont (runtime)

+ (void)load{
    
    //获取替换后的类方法
    Method newMethod = class_getClassMethod([self class], @selector(adjustFont:));
    //获取替换前的类方法
    Method oldMethod = class_getClassMethod([self class], @selector(systemFontOfSize:));
    
    //然后交换类方法
    method_exchangeImplementations(newMethod, oldMethod);
    
}

+(UIFont *)adjustFont:(CGFloat)fontSize{
    UIFont *newFont = nil;
    newFont = [UIFont adjustFont:fontSize*[UIScreen mainScreen].bounds.size.width/EquipmentUIScreen];
    return newFont;
}

@end
